using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class WarehouseList : MonoBehaviour
{
    public GameObject m_Content;
    public WarehouseItem m_WarehousePrefab;
    public List<WarehouseItem> m_WarehouseList = new List<WarehouseItem>();

    private void Awake()
    {
    }
    void Start()
    {

        Init();
    }

    // Update is called once per frame
    void Update()
    {
        
    }
    void Init()
    {
        var player = PlayerManager.Instance.playerSelf;
        foreach (var i in player.ships)
        {
            var warehouse = Instantiate(m_WarehousePrefab);
            warehouse.Init(i.m_Warehouse);
            warehouse.gameObject.transform.SetParent(m_Content.transform);
            warehouse.gameObject.transform.SetSiblingIndex(m_Content.transform.childCount - 2);
            i.m_Warehouse.onAddItem.AddListener(warehouse.OnWarehouseAddItem);
            m_WarehouseList.Add(warehouse);
        }
    }
}
